// app.js
const validator  = require("./custom/validator");
const resCode = require("./custom/code");
const commConst = require("./custom/const");
class AppBootHook {
    constructor(app) {
      this.app = app;
    }
  
    configWillLoad() {
      // The config file has been read and merged, but it has not yet taken effect
      // This is the last time the application layer modifies the configuration
      // Note: This function only supports synchronous calls.
  
      // For example: the password in the parameter is encrypted, decrypt it here
     
     
    }
  
    async didLoad() {
      // All configurations have been loaded
      // Can be used to load the application custom file, start a custom service
  
      // Example: Creating a custom app example
      
    }
  
    async willReady() {
      // All plugins have been started, but the application is not yet ready
      // Can do some data initialization and other operations
      // Application will start after these operations executed succcessfully
  
      // For example: loading data from the database into the in-memory cache
      //this.app.cacheData = await this.app.model.query(QUERY_CACHE_SQL);
      let app = this.app;
      validator(app);

      this.app.cacheData = {"cacheData":"cacheData11111111111111111111111111111"};


       this.app.resCode = resCode;
       this.app.const = commConst;
    }
  
    async didReady() {
      // Application already ready
    
    }
  
    async serverDidReady() {
      // http / https server has started and begins accepting external requests
      // At this point you can get an instance of server from app.server
  
   
    }
  }
  
  module.exports = AppBootHook;